package course.mycollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class MyCollectionDemo3 {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        list.add("e");

        //1.获得迭代器对象
        Iterator<String> it = list.iterator();
//
//        System.out.println(it.hasNext());
//        //取出当前元素，将迭代器往后移动一个索引位置
//        System.out.println(it.next());

        while (it.hasNext()){
            System.out.println(it.next());
        }

    }
}
